package com.LeeCode;

import java.util.HashSet;
import java.util.Set;

/**
 * 开幕式焰火
 */

public class CodeLCP044 {
    public static void main(String[] args) {
        Integer[] arr = {1, 3, 2, 1, null, 2};
        TreeNode root = Utils.buildTree(arr);
        System.out.println(new CodeLCP044().numColor(root));
    }

    public int numColor(TreeNode root) {
        Set<Integer> set = new HashSet<>();
        postOrder(root, set);
        return set.size();
    }

    private void postOrder(TreeNode root, Set<Integer> set) {
        if (root == null) return;
        postOrder(root.left, set);
        postOrder(root.right, set);

        set.add(root.val);
    }
}
